<!doctype html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>控制台 </title>
<meta name="author" content="" />
<link href="favicon.ico" rel="shortcut icon">
<link rel="stylesheet" type="text/css" th:href="@{/css/console.css}" href="../../../css/reset.min.css"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/reset.min.css}" href="../../../css/console.css"/>
</head>

<body>
<div class="mb">
	<pre class="i-has-teh-code">
	<command style = "display: block">$: > 启动完成 ■■■■■■■■■■■ 100%</command>
	<command style = "display: block">$: > 但愿是春日安好</command>
	<command style = "display: block">$: > 晚后是山花烂漫   </command>
	<command style = "display: block">$: > 我抓不住世间的美好 </command>
	<command style = "display: block">$: > 只能装作万事顺遂的模样</command>
	<command style = "display: block">$: > 欲言又止就是答案 悬而不决 熬人且无益</command>
	<command id="command"></command>
	</pre>
	<input class="in" />
</div>

<div th:replace="common/common_foot :: foot"></div>
<!-- 引入main.js -->
<script th:src="@{/js/me/main.js}" src='../../..'></script>
<script type="text/javascript">
	var websocket
	$(document).ready(function() {
		// 指定websocket路径
		websocket = new WebSocket('ws://localhost:8082/websocket');
		websocket.onmessage = function(event) {
			// 接收服务端的实时日志并添加到HTML页面中
			//初始化赋值显示
			Console.render({
				text:event.data   //text 需要显示在控制台的字符
			})
			// $("#log-container div").append(event.data);
			// // 滚动条滚动到最低部
			// $("#log-container").scrollTop($("#log-container div").height() - $("#log-container").height());
		};
	});

	document.onkeydown = function (event){
    let value = Console.inp.value;
    let e = event || window.event;
    if (e && e.keyCode === 13){

       //初始化赋值显示
		Console.render({
			text:value   //text 需要显示在控制台的字符
		})

		// 发送消息
		websocket.send(JSON.stringify(value));
    }
}

</script>
</body>
</html>
